package cn.tedu.maxscore;

import java.io.IOException;

import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Reducer;

public class MaxScoreReducer
		extends Reducer<Text,IntWritable,Text,IntWritable>{
	@Override
	protected void reduce(Text key, Iterable<IntWritable> values,
						  Reducer<Text, IntWritable, Text, IntWritable>.Context context)
			throws IOException, InterruptedException {
		//在这里，我们要筛选出最高的分数
		int max = 0;
		//把存有的分数，遍历出来，与max进行比较，
		//如果value大，那么把max重新赋值为value
		for (IntWritable value : values) {
			if(max <value.get()) {
				max = value.get();
			}
		}
		context.write(key, new IntWritable(max));
	}
}
